package Day08_17;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test_FileOutputStream {
    public static void main(String[] args) {
        FileOutputStream fos = null;

        try {
            fos = new FileOutputStream("myFile",true);
            byte[] bytes = {96,97,98,99,100};
            fos.write(bytes);

            String s = "别再想了，否则后果很严重";
            byte[] bytes1 = s.getBytes();

            fos.write(bytes1);
            fos.write(bytes1);
            fos.write(bytes1);
            fos.write(bytes1);
            fos.write(bytes1);






            fos.flush();
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if(fos!=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
